<template>
	<view class="">
		<view class="flex1 p10 " style="background-color: #FFF;">
			<view class="" style="width: 100rpx;height: 100rpx;border-radius: 50%;">
				<image class="photo" :src="addFriendlist.photo"  mode="" style="border-radius: 50%;"></image>
			</view>
			<view class="ml-30">
				<view class="fw">
					{{addFriendlist.username}}
				</view>
				<view class="size-24 mt-20">
					ID:{{user_id}}
				</view>
				<view class="size-24 mt-20">
						{{addFriendlist.doodling}}
				</view>
			</view>
		</view>
		<view class="mt-20 ml-20 size-28">
			请填写验证信息
		</view>
		<view class="mt-20" style="background-color: #FFF;">
			<textarea v-model="value" @input="handletextarea"></textarea>
		</view>
		<view class="mt-20 ml-20 size-28">
			请填写备注和分组
		</view>
		<view class="p10 mt-20 fw" style="background-color: #FFF;border-bottom: 1rpx solid #EDEDED;">
			备注
		</view>
		<view class="flex1 flex-between" style="background-color: #FFF;align-items: center;">
			<view class="p10 fw">
				分组
			</view>
			<view class="flex1 ">
				<view class="">
					我的朋友
				</view>
				<view class=" mlr-30">
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
		</view>
		<view class="mt-50 p10 center" style="background-color: #FFF;align-items: center;color: #3C71CA;"
			@click="sendmessagefriend()">
			发送
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:'',
				user_id: '',
				addFriendlist: {}
			}
		},
		onLoad(options) {
			console.log(options.user_id);
			this.user_id = options.user_id
		},
		onShow() {
			var params = {
				_token: uni.getStorageSync('im_token'),
				user_id: this.user_id,
				_agent_id: 1,
				in: 0,
			}
			uni.request({
				url: `http://im.ezongguan.com/im/get/details`,
				method: 'POST',
				data: params,
				success: (res) => {
					console.log(res.data.data)
					this.addFriendlist = res.data.data
				},
			})
		},
		methods: {
			handletextarea(e){
				// console.log(e.detail.value);
				this.value=e.detail.value
			},
			// 发送好友申请
			sendmessagefriend() {
				// console.log(this.value);
				var params = {
					_token: uni.getStorageSync('im_token'),
					user_id: this.user_id,
					content:this.value,
					is_type: 0,
				}
				uni.request({
					url: `http://im.ezongguan.com/im/action/friendAdd`,
					method: 'POST',
					data: params,
					success: (res) => {
						console.log(res)
						uni.showToast({
							title:res.data.msg
						})
						setTimeout(()=>{
							uni.navigateBack({
								url:'/pages/chip/index'
							})
						},1000)
					},
				})
			}
		}

	}
</script>

<style lang="less" scoped>
	page {
		background-color: #e5e5e6;
	}
</style>
